package com.shengchang.hu.supervision.Utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by Administrator on 2017/11/24 0024.
 */

public class SPManager {
    private static SPManager sSPManager;
    private Context mContext;
    private SharedPreferences mPref;

    public static SPManager getInstance()
    {
        if (sSPManager == null) {
            sSPManager = new SPManager();
        }
        return sSPManager;
    }

    private SharedPreferences getPref()
    {
        if (this.mPref == null) {
            this.mPref = PreferenceManager.getDefaultSharedPreferences(this.mContext);
        }
        return this.mPref;
    }

    public boolean getBoolean(String paramString, boolean paramBoolean)
    {
        return getPref().getBoolean(paramString, paramBoolean);
    }

    public int getInt(String paramString, int paramInt)
    {
        return getPref().getInt(paramString, paramInt);
    }

    public long getLong(String paramString, long paramLong)
    {
        return getPref().getLong(paramString, paramLong);
    }

    public String getString(String paramString1, String paramString2)
    {
        return getPref().getString(paramString1, paramString2);
    }

    public void init(Context paramContext)
    {
        this.mContext = paramContext;
    }

    public void putBoolean(String paramString, boolean paramBoolean)
    {
        getPref().edit().putBoolean(paramString, paramBoolean).commit();
    }

    public void putInt(String paramString, int paramInt)
    {
        getPref().edit().putInt(paramString, paramInt).commit();
    }

    public void putLong(String paramString, Long paramLong)
    {
        getPref().edit().putLong(paramString, paramLong.longValue()).commit();
    }

    public void putString(String paramString1, String paramString2)
    {
        getPref().edit().putString(paramString1, paramString2).commit();
    }

}
